<template>
  <div class="met-news-body" >
    <div class="met-news-list">
      <ul class="ul">
        <li v-for="item in news_list" :key="item.id">
          <div class="media" v-if="listStyle==='image'">
            <div class="img">
              <img mode="widthFix" style="width:100%;" :src="item.imgurl" alt="">
            </div>
            <div class="content">
              <h4 class="title" @click="handleLink(item)" :style="{color:app_tabBar.config.firstcolor}">
                {{item.title}}
              </h4>
              <p class="desc" :style="{color:app_tabBar.config.secondcolor}">
                {{item.description}}
              </p>
              <p class="info">
                <span class="time" :style="{color:app_tabBar.config.secondcolor}">{{item.addtime}}</span>
                <span class="admin" :style="{color:app_tabBar.config.secondcolor}">
                  <i class="fa fa-user" />&nbsp;{{item.issue}}</span>
                <span class="hits" :style="{color:app_tabBar.config.secondcolor}">
                  <i class="fa fa-eye" />&nbsp;{{item.hits}}</span>
              </p>
            </div>
          </div>
          <div class="media" v-else>
            <div class="content">
              <h4 class="title" @click="handleLink(item)" :style="{color:app_tabBar.config.firstcolor}">
                {{item.title}}
              </h4>
              <p class="desc" :style="{color:app_tabBar.config.secondcolor}">
                {{item.description}}
              </p>
              <p class="info">
                <span class="time" :style="{color:app_tabBar.config.secondcolor}">{{item.addtime}}</span>
                <span class="admin" v-if="item.issue!==''" :style="{color:app_tabBar.config.secondcolor}">
                  <i class="fa fa-user" />&nbsp;{{item.issue}}</span>
                <span class="hits" :style="{color:app_tabBar.config.secondcolor}">
                  <i class="fa fa-eye" />&nbsp;{{item.hits}}</span>
              </p>
            </div>
          </div>
        </li>
      </ul>
      <div v-if="news_list.length===0" :style="'color:red'">
        数据不能为空
      </div>
    </div>
  </div>
</template>
<script>
import { mapGetters } from 'vuex'
export default {
  props: {
    listStyle: String
  },
  computed: {
    ...mapGetters(['news_list', 'app_viewHeight', 'app_tabBar'])
  },
  data() {
    return {}
  },
  methods: {
    handleLink(item) {
      const param = {
        id: item.id,
        module: item.module
      }
      this.$store.dispatch('GetNewsView', param).then(response => {})
      const data = {
        module: item.module
      }
      this.$store.dispatch('GetSidebar', data).then(response => {})
      this.$router.push('/shownews/index')
    }
  }
}
</script>
<style lang="scss" scoped>
.met-news-body {
  padding: 15px;
  .met-news-list {
    .media {
      display: flex;
      padding-bottom: 20px;
      margin-bottom: 20px;
      border-bottom: 1px solid #dcdcdc;
      position: relative;
      &:before {
        position: absolute;
        content: '';
        width: 10px;
        height: 1px;
        background-color: #000000;
        bottom: 0;
        -webkit-transition: all 0.66s cubic-bezier(0.17, 0.84, 0.44, 1);
        transition: all 0.66s cubic-bezier(0.17, 0.84, 0.44, 1);
      }
      .img {
        width: 120px;
      }
      .content {
        padding-left: 10px;
        flex: 1;
        .title {
          font-size: 16px;
          margin-bottom: 5px;
          color: #000;
        }
        .desc {
          color: #999999;
          font-size: 13px;
          margin-bottom: 5px;
          overflow: hidden;
          text-overflow: ellipsis;
          display: -webkit-box;
          -webkit-line-clamp: 2;
          -webkit-box-orient: vertical;
          font-weight: 300;
          height: 40px;
        }
        .info {
          font-size: 14px;
          color: #999999;
          font-weight: 300;
          margin-top: 10px;
          .fa {
            margin-right: 8px;
          }
          span {
            margin-left: 10px;
          }
          .time {
            margin-left: 0;
          }
        }
      }
    }
  }
}
</style>